home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / DimText 2.0 / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-14  |  1.4 KB  |  75 lines  |  [TEXT/KAHL]

  1. #include <Dialogs.h>
  2. #include <Menus.h>
  3.  
  4. #include "ToolBoxInit.h"
  5. #include "Dim_text.h"
  6.  
  7. enum {    // dialog item numbers
  8.     i_done = 1,
  9.     i_title,
  10.     i_checkbox1,
  11.     i_checkbox2,
  12.     i_stat1,
  13.     i_edit1,
  14.     i_edit3,
  15.     i_stat2,
  16.     i_edit2,
  17.     i_refresh
  18. };
  19.  
  20. void main( void )
  21. {
  22.     DialogPtr    dp;
  23.     ControlHandle    checkbox1, checkbox2;
  24.     Rect            iRect;
  25.     short            iType, hit, val;
  26.     MenuHandle        apple_menu;
  27.     
  28.     ToolBoxInit();
  29.     apple_menu = NewMenu( 128, "\p\x14" );
  30.     AppendMenu( apple_menu, "\pYo;(-" );
  31.     AddResMenu( apple_menu, 'DRVR' );
  32.     InsertMenu( apple_menu, 0 );
  33.     DrawMenuBar();
  34.     
  35.     dp = GetNewDialog( 128, NULL, (WindowPtr)-1L );
  36.     SetPort( dp );
  37.     GetDItem( dp, i_checkbox1, &iType, (Handle *)&checkbox1, &iRect );
  38.     GetDItem( dp, i_checkbox2, &iType, (Handle *)&checkbox2, &iRect );
  39.     Init_dimmer( dp );
  40.     
  41.     ShowWindow( dp );
  42.     do {
  43.         ModalDialog( NULL, &hit );
  44.         switch (hit)
  45.         {
  46.             case i_checkbox1:
  47.                 val = !GetCtlValue( checkbox1 );
  48.                 SetCtlValue( checkbox1, val );
  49.                 Dim_text( dp, i_stat1, val );
  50.                 Dim_text( dp, i_edit1, val );
  51.                 Dim_text( dp, i_edit3, val );
  52.                 break;
  53.                 
  54.             case i_checkbox2:
  55.                 val = !GetCtlValue( checkbox2 );
  56.                 if (val)
  57.                 {
  58.                     Alert( 129, NULL );
  59.                 }
  60.                 SetCtlValue( checkbox2, val );
  61.                 Dim_text( dp, i_stat2, val );
  62.                 Dim_text( dp, i_edit2, val );
  63.                 break;
  64.             
  65.             case i_refresh:
  66.                 EraseRect( &dp->portRect );
  67.                 InvalRect( &dp->portRect );
  68.                 break;
  69.         }
  70.     } while (hit != i_done);
  71.     
  72.     Dispose_dimmer( dp );
  73.     DisposeDialog( dp );
  74. }
  75.